/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.baumi.tankwars.util;

import org.lwjgl.Sys;

/**
 *
 * @author Michael Baumgartner
 */
public class Timer {

    private long lastFrame;
    private long lastFPS;
    private int fps;

    public Timer(){};
    public Timer(long lastFrame, long lastFPS, int fps) {
        this.lastFrame = lastFrame;
        this.lastFPS = lastFPS;
        this.fps = fps;
    }

    public long getLastFrame() {
        return lastFrame;
    }

    public void setLastFrame(long lastFrame) {
        this.lastFrame = lastFrame;
    }

    public long getLastFPS() {
        return lastFPS;
    }

    public void setLastFPS(long lastFPS) {
        this.lastFPS = lastFPS;
    }

    public int getFps() {
        return fps;
    }

    public void setFps(int fps) {
        this.fps = fps;
    }

    public static long  getTime() {
        return (Sys.getTime() * 1000 / Sys.getTimerResolution());
    }

    public int getDelta() {
        long time = getTime();
        int delta = (int) (time - lastFrame);
        lastFrame = time;

        return delta;
    }

    public void init() {
        this.lastFrame = getTime();
        this.lastFPS = getTime();
    }
}
